import pygame
from gui import *
from vector import vector
class App:
    def __init__(self):
        self.running = True
        self.display = None
        self.frameCount = 0
    def init(self):
        pygame.init()
        self.display = pygame.display.set_mode((640,400), pygame.HWSURFACE)
        self.running = True
        self.gui = gui_handler(self.display)
        self.w=self.gui.addWindow(200,250,"Okno",vector(100,100))
    def event(self, event):
        if event.type == pygame.QUIT:
            self.running = False
            pygame.quit()
    def loop(self):
        pygame.display.flip()
    def cleanup(self):
        pygame.quit()
    def red(self):
        self.w.color((255,0,0))
    def green(self):
        self.w.color((0,255,0))
    def blue(self):
        self.w.color((0,0,255))
    def white(self):
        self.w.color((255,255,255))
    def execute(self):
        self.gui.addButton("Red",self.w,self.red)
        self.gui.addButton("Blue",self.w,self.blue)
        self.gui.addButton("Green",self.w,self.green)
        slider = self.gui.addSlider("Alpha",100,self.w)
        slider2 = self.gui.addSlider("Value",100,self.w)
        while self.running:
            self.w.alpha(slider.get())
            self.display.fill((0,0,0))
            self.gui.update()
            for event in pygame.event.get():
                self.event(event)
            self.loop()
        self.cleanup()
a = App()
a.init()
a.execute()
